/**
* Field consumer that shows the value of specified attribute to GUI
**/
jsx3.Class.defineClass(
	"ux.cdb.admin.dataautomate.RadioUpdater",
	ux.cdb.admin.dataautomate.GenericUpdater, null,
	function (block) {

		/**
		* instance initializer
		* @param strName {String} unique name distinguishing this object from all other JSX GUI objects in the JSX application
		* @param vntLeft {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntTop {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntWidth {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntHeight {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param strHTML {String} Text/HTML markup to place in the jsx3.gui.Block instance
		*/
		block.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML) {
			//call constructor for super class (the super expects the name of the object and the function that it is an instance of)
			this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
		};
		
		block.prototype.applyData = function(data) {
			var me = this;
			var val = data[this.uxdataatt];
			var radios = this.getDescendantsOfType(jsx3.gui.RadioButton);
			for(var i=0;i<radios.length;i++){
				var radio = radios[i];
				if(radio.getValue() == val){
					radio.setSelected(jsx3.gui.RadioButton.SELECTED);
					break;
				}
			}
		};
		
		block.prototype.extractData = function(){
			var radios = this.getDescendantsOfType(jsx3.gui.RadioButton);
			for(var i=0;i<radios.length;i++){
				var radio = radios[i];
				if(radio.getSelected() == jsx3.gui.RadioButton.SELECTED) {
					return radio.getValue();
                }
			}
			return null;
		};
		
		//methods from IExtractor interface for support validation correctly
		block.prototype._validateFailedUI = function(failed,message){
			var objText = this.getDescendantOfName("block");
			
			if(failed === true){
				objText.setBackgroundColor(ux.megatron.Main.getServer().getDynamicProperty("@cdb@Validation Failed BGColor"), true);
				objText.setTip((message) ? message : "");
			}else{
				objText.setBackgroundColor("#FFFFFF", true);
				objText.setTip("");
			}
		};

		block.prototype.getValidateHelper_require_errorMsg = function(){
            return 'You need to check a radio box to make your decision';
        };
	});